let events = []

exports.on = function(name,observer,callback){
  if( events.find(event=>event.name === name && event.callback == callback) ) 
    return;

  events.push({name,observer,callback});
}

exports.emit = function(name,data = null){
  events.filter(event => event.name == name).forEach(event=>event.callback.call(event.observer,data))
}

exports.remove = function(observer,name=null){
  events = events.filter(event => event.observer !== observer || (name && event.name!==name))
}